package com.laobiao.file_netty_lib.netty.server;

import java.io.File;

import com.laobiao.file_netty_lib.exception.FileBaseException;
/**
 * 服务端全局配置
 * @author 38079
 *
 */
public class ServerApplication {
	/**
	 * 服务本地根目录
	 */
	private static File localBaseDir;

	public static File getLocalBaseDir() {
		if(localBaseDir==null || !localBaseDir.exists() ||!localBaseDir.isDirectory()) {
			throw new FileBaseException("未设置服务本地基础目录！", FileBaseException.ERR_PARAM_NULL);
		}
		return localBaseDir;
	}
	/**
	 * 设置服务本地根目录
	 */
	public static void setLocalBaseDir(String localBaseDirPath) {
		if(localBaseDirPath==null || "".equals(localBaseDirPath.trim())) {
			throw new FileBaseException("服务本地基础路径不能为空！", FileBaseException.ERR_PARAM_NULL);
		}
		localBaseDir=new File(localBaseDirPath);
		if(!localBaseDir.exists() || !localBaseDir.isDirectory()) {
			localBaseDir.mkdirs();
		}
	}
	public static String getServerBasePath() {
		// TODO Auto-generated method stub
		return getLocalBaseDir().getAbsolutePath();
	}
	
}
